﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeakScript
{
    class FunctionManager
    {
        public delegate void WeakFunctionDelegate(List<WeakVar> args);

        Dictionary<string, WeakFunctionDelegate> _functions;

        public FunctionManager()
        {
            _functions = new Dictionary<string, WeakFunctionDelegate>();
        }

        public void RegistrateFunction(string name, WeakFunctionDelegate func)
        {
            if (_functions.Keys.Contains<string>(name)) return;
            _functions[name] = func;
        }

        internal bool ProcessFunction(string name, List<WeakVar> args)
        {
            if (_functions.Keys.Contains<string>(name))
            {
                _functions[name](args);
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
